package com.bear.newsset.ui.activity;

import android.app.Application;

import com.bear.newsset.dao.SQLAction;
import com.bear.newsset.dao.entity.AccountEntity;
import com.bear.newsset.util.LogUtils;
import com.tencent.smtt.sdk.QbSdk;
import com.ybear.networkutil.HttpManage;

/**
 * Newsset Application
 */
public class NSApplication extends Application {
    private AccountEntity accountEntity;

    @Override
    public void onCreate() {
        super.onCreate();
        init();
    }
    
    private void init() {
        SQLAction.getInstance().init( this );
        HttpManage.getInstance().init( this );
        initX5();
    }

    private void initX5() {
        //任何网络下都允许下载内核
        QbSdk.setDownloadWithoutWifi( true );
        //x5内核初始化接口，搜集本地tbs内核信息并上报服务器，服务器返回结果决定使用哪个内核。
        QbSdk.initX5Environment(getApplicationContext(), new QbSdk.PreInitCallback() {
            @Override
            public void onCoreInitFinished() { }
            @Override
            public void onViewInitFinished(boolean b) {
                //x5內核初始化完成的回调，为true表示x5内核加载成功，否则表示x5内核加载失败，会自动切换到系统内核。
                LogUtils.d("initX5", "onViewInitFinished:" + b);
            }
        });

    }

    public AccountEntity getAccountEntity() {
        return accountEntity;
    }

    public NSApplication setAccountEntity(AccountEntity accountEntity) {
        this.accountEntity = accountEntity;
        return this;
    }
}
